<?php

App::uses('AppModel', 'Model');

/**
 * Country
 *
 * PHP version 5
 *
 * @category Model
 * @package  Countries
 * @version  1.0
 * @author   Fahad Ibnay Heylaal <contact@fahad19.com>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://www.croogo.org
 */
class Country extends AppModel {


	public $validate = array(
		'name' => array(
			'rule' => array('minLength', 1),
			'message' => 'Name cannot be empty.',
		),
		'alias' => array(
			'isUnique' => array(
				'rule' => 'isUnique',
				'message' => 'This alias has already been taken.',
			),
			'minLength' => array(
				'rule' => array('minLength', 1),
				'message' => 'Alias cannot be empty.',
			),
		)	
	);

/**
 * Filter search fields
 *
 * @var array
 * @access public
 */
	public $filterArgs = array(
		'name' => array('type' => 'like', 'field' => array('Country.name'))
	);	
	
/**
 * Model associations: hasMany
 *
 * @var array
 * @access public
 */
	public $hasMany = array(
		'City' => array(
			'className' => 'City',
			'foreignKey' => 'country_id',
			'dependent' => true,
			'conditions' => '',
			'fields' => '',
			'order' => 'City.weight ASC',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => '',
		),
	);
}
?>